define(function(require, exports){
	var pubjs = require('pubjs');
	var view = require('@base/view');
	var $ = require('jquery');
	var util = require('util');

	var Popwin = view.widget.extend({
		init: function(config){
			config = pubjs.conf(config, {
				'class': 'P-spot',
				'url': '',
				"layout": {
					"module": '@base/dialog.base',
					"mask": 1,
					"showFoot": true, // 显示底层的取消和完成按钮
					"size": 'm',
					"close": null,
					"silence": false // 点击按钮发消息
				}
			});
			//缓存需要修改的广告位id
			this.$ids = null;
			//缓存发送请求的数据类型
			this.$type = null;
			this.Super('init', arguments);
		},
		afterBuild: function() {
			var c = this.getConfig();
			var el = this.getDOM();
			$('<div pub-name="adx" pub-mod="ptc/action/adx.edit">').appendTo(el);
			this.buildFromTemplate({ adx: {
				isPop: true
			}});
		},
		onDialogOk: function(ev){
			var self = this;
			this.$.adx.save(function() {
				self.fire('saveRecord');
			});
			return false;
		},
		reload: function(id) {
			this.$.adx.load(id);
			return this;
		},
		onDialogCancel: function(){
			this.reset().hide();
		},
		reset: function(){
			this.$.adx.reset();
			return this;
		}
	});
	exports.base = Popwin;
});